#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
int main()
{
    pid_t id = fork();
    if(id < 0)
    {
        perror("fork");
        return 0;
    }
    if(id == 0)
    {
        int cn = 5;
        while(cn--)
        {
            printf("i am child process,pid: %d, ppid: %d\n", getpid(), getppid());
            sleep(1);
        }
    }
    else if(id > 0)
    {       
        int cn = 10;
        while(cn--)
        {
            printf("i am parent processpid: %d, ppid: %d\n", getpid(), getppid());
            sleep(1);
        }
        pid_t ret = wait(NULL);
        if(ret == id)
        {
            printf("wait success, ret = %d", ret);
        }
        sleep(5);
    }
    return 0;
}
